package com.example.parkingsharing.utils

import android.content.Context
import android.view.View
import android.view.WindowManager
import androidx.compose.runtime.Composable
import androidx.core.view.WindowCompat
import java.io.BufferedWriter
import java.io.FileInputStream
import java.io.IOException
import java.io.OutputStreamWriter

/**
 * 随机生成长度为length的字符串
 */
fun getRandomString(length: Int) : String {
    val allowedChars = ('A'..'Z') + ('a'..'z') + ('0'..'9')
    return (1..length)
        .map { allowedChars.random() }
        .joinToString("")
}

private fun hideStatusBar(model:Int = 0, content: @Composable () -> Unit){
    when(model) {
        0 -> {
            // 沉浸式状态栏 方法一
//            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
//            window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
//                    or View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
//            window.statusBarColor = android.graphics.Color.TRANSPARENT
        }
        1 -> {
            // 设置装饰适配系统窗口 方法二
//            WindowCompat.setDecorFitsSystemWindows(window, false)
//            ...
//            ProvideWindowInsets {
//                rememberSystemUiController().setStatusBarColor(
//                    Color.Transparent, darkIcons = MaterialTheme.colors.isLight
//                )
//            }
        }
    }
}
